package cn.otrue.patienthealthmanager.http;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import cn.otrue.patienthealthmanager.HealthApplication;
import cn.otrue.patienthealthmanager.utils.CommonUtil;

import com.lidroid.xutils.exception.HttpException;
import com.lidroid.xutils.http.ResponseInfo;
import com.lidroid.xutils.http.callback.RequestCallBack;

/**
 * 
 * @author G
 * 
 */
public class MyRequestCallBack extends RequestCallBack<String> {

	Message msg;
	Bundle data;
	Handler handler;

	public MyRequestCallBack(Message msg, Bundle data, Handler handler) {
		this.msg = msg;
		this.data = data;
		this.handler = handler;
	}

	@Override
	public void onFailure(HttpException arg0, String arg1) {
		// 网络异常是存储状态为EXCEPTION
		if (CommonUtil.isNetConnected(HealthApplication.getInstance())) {

			data.putString(HttpCons.STATE, HttpCons.STATE_EXCEPTION);
			msg.setData(data);
			handler.sendMessage(msg);
		}
	}

	@Override
	public void onSuccess(ResponseInfo<String> arg0) {
	}
}
